home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: william.mc@pi.se (William McIlhagga)
- Newsgroups: comp.std.c++
- Subject: RE: Inherent C++ problem??
- Date: 6 Feb 1996 16:08:35 GMT
- Organization: ?
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <199602060648.HAA19423@mail.pi.se>
- NNTP-Posting-Host: taumet.eng.sun.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset="us-ascii"
- X-Sender: m1717@mail.pi.se (Unverified)
- X-Mailer: Windows Eudora Version 1.4.4
- X-Lines: 40
- Content-Length: 1855
- Originator: clamage@taumet
-
- Regarding the eliding of copy constructors, John Max Skaller wrote:
-
- > Completely irrelevent. The compiler is permitted to elide
- >the copy constructor anyhow. If this changes the observable behaviour
- >of you program it's your own fault that your code is not deterministic.
-
- There are a few points to note about "determinism":
-
- 1) The standard says that an implementation *may* get rid of some copy
- constructors; it does not demand it. Thus the indeterminism lies in the fact
- that the programmer does not know whether this has happened to their code,
- unless the compiler is kind enough to say so (compilers are the strong
- silent type, and don't usually tell you anything about what they're thinking)
- 2) Removing copy constructors is intended as an optimisation. But
- optimisations should never change the meaning of a program - that is, the
- program should produce the same results with and without the optimisation.
- Clearly, removing "irrelevant" copy constructors is a different kind of
- thing altogether.
-
- I think this part of the standard is a little dangerous. I accept that
- removing copy constructors is a useful optimisation however (though I
- haven't seen any benchmarks to show how big a speedup you get - perhaps
- someone could post some to convince us all that it's worthwhile). There are
- a few things that might improve the situation:
-
- 1) if an implemention removes a copy constructor, the standard should demand
- that it issues a warning message (if the user desires...). Though I guess
- most people will turn this warning off after a couple of hours, so maybe
- that's not so smart.
- 2) the standard should include some specified way of switching off the
- removal of copy constructors. If it's in the standard then it's
- transportable, so no problems there. Perhaps some ugly #pragma or something?
-
-
- Cheers,
-
- William McIlhagga
- william.mc@pi.se
-
-
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is
- summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- ]
-